const defs = {
    root: {
        icon: '_root_folder',
        format: 'svg'
    },
    default: {
        icon: '_default_folder',
        format: 'svg'
    },
    supported: [
        { icon: 'android', format: 'svg', names: ['android'] },
        { icon: 'api', format: 'svg', names: ['api', '.api', 'apis', '.apis'] },
        { icon: 'app', format: 'svg', names: ['app', 'apps', '.app'] },
        { icon: 'arangodb', format: 'svg', names: ['arangodb', 'arango'] },
        { icon: 'asset', format: 'svg', names: ['assets', '.assets'] },
        { icon: 'aurelia', format: 'svg', names: ['aurelia_project'] },
        {
            icon: 'audio',
            format: 'svg',
            names: ['audio', '.audio', 'audios', '.audios', 'sound', '.sound', 'sounds', '.sounds']
        },
        { icon: 'aws', format: 'svg', names: ['aws', '.aws'] },
        { icon: 'azure', format: 'svg', names: ['azure', '.azure'] },
        { icon: 'azurepipelines', format: 'svg', names: ['azure-pipelines', '.azure-pipelines'] },
        { icon: 'binary', format: 'svg', names: ['bin', '.bin'] },
        { icon: 'bloc', format: 'svg', names: ['blocs', 'bloc'] },
        {
            icon: 'blueprint',
            format: 'svg',
            names: ['blueprint', '.blueprint', 'blueprints', '.blueprints']
        },
        { icon: 'bot', format: 'svg', names: ['bot', '.bot'] },
        { icon: 'bower', format: 'svg', names: ['bower_components'] },
        { icon: 'buildkite', format: 'svg', names: ['.buildkite'] },
        { icon: 'cake', format: 'svg', names: ['cake', '.cake'] },
        {
            icon: 'certificate',
            format: 'svg',
            names: ['certificates', '.certificates', 'certs', 'certs.']
        },
        { icon: 'changesets', format: 'svg', names: ['.changeset'] },
        { icon: 'chef', format: 'svg', names: ['chef', '.chef'] },
        { icon: 'circleci', format: 'svg', names: ['.circleci'] },
        {
            icon: 'controller',
            format: 'svg',
            names: ['controller', 'controllers', '.controllers', 'handlers', '.handlers']
        },
        {
            icon: 'component',
            format: 'svg',
            names: ['component', 'components', '.components', 'gui', 'src-ui', 'ui', 'widgets']
        },
        { icon: 'composer', format: 'svg', names: ['composer', '.composer'] },
        {
            icon: 'cli',
            format: 'svg',
            names: ['cli', 'cmd', 'command', 'commands', 'commandline', 'console']
        },
        { icon: 'client', format: 'svg', names: ['client', 'clients'] },
        { icon: 'cmake', format: 'svg', names: ['.cmake', 'cmake'] },
        { icon: 'common', format: 'svg', names: ['common'] },
        {
            icon: 'config',
            format: 'svg',
            names: [
                'conf',
                '.conf',
                'config',
                '.config',
                'configs',
                '.configs',
                'configuration',
                '.configuration',
                'configurations',
                '.configurations',
                'setting',
                '.setting',
                'settings',
                '.settings',
                'ini',
                '.ini',
                'initializers',
                '.initializers'
            ]
        },
        { icon: 'coverage', format: 'svg', names: ['coverage'] },
        { icon: 'css', format: 'svg', names: ['css', '_css'] },
        { icon: 'cubit', format: 'svg', names: ['cubits', 'cubit'] },
        { icon: 'cypress', light: true, format: 'svg', names: ['cypress'] },
        { icon: 'dapr', format: 'svg', names: ['.dapr', 'dapr'] },
        { icon: 'datadog', format: 'svg', names: ['datadog', '.datadog'] },
        {
            icon: 'db',
            format: 'svg',
            names: ['db', 'database', 'sql', 'data', 'repo', 'repository', 'repositories']
        },
        { icon: 'debian', format: 'svg', names: ['debian', 'deb'] },
        { icon: 'dependabot', format: 'svg', names: ['.dependabot'] },
        { icon: 'devcontainer', format: 'svg', names: ['.devcontainer'] },
        {
            icon: 'dist',
            format: 'svg',
            names: [
                'dist',
                '.dist',
                'dists',
                'out',
                'outs',
                'export',
                'exports',
                'build',
                '.build',
                'builds',
                'release',
                'releases',
                'target',
                'targets'
            ]
        },
        { icon: 'docker', format: 'svg', names: ['docker', '.docker'] },
        { icon: 'docs', format: 'svg', names: ['docs', 'doc', 'document', 'documents'] },
        { icon: 'e2e', format: 'svg', names: ['e2e'] },
        {
            icon: 'elasticbeanstalk',
            format: 'svg',
            names: ['.elasticbeanstalk', '.ebextensions']
        },
        { icon: 'electron', light: true, format: 'svg', names: ['electron'] },
        { icon: 'expo', light: true, format: 'svg', names: ['.expo', '.expo-shared'] },
        { icon: 'favicon', format: 'svg', names: ['favicon', 'favicons'] },
        { icon: 'frontcommerce', format: 'svg', names: ['.front-commerce'] },
        { icon: 'flow', format: 'svg', names: ['flow', 'flow-typed'] },
        { icon: 'fonts', light: true, format: 'svg', names: ['fonts', 'font', 'fnt'] },
        { icon: 'gcp', format: 'svg', names: ['gcp', '.gcp'] },
        { icon: 'git', format: 'svg', names: ['.git', 'submodules', '.submodules'] },
        { icon: 'github', format: 'svg', names: ['.github'] },
        { icon: 'gitlab', format: 'svg', names: ['.gitlab'] },
        { icon: 'gradle', light: true, format: 'svg', names: ['gradle', '.gradle'] },
        { icon: 'graphql', format: 'svg', names: ['graphql'] },
        { icon: 'grunt', format: 'svg', names: ['grunt'] },
        {
            icon: 'gulp',
            format: 'svg',
            names: [
                'gulp',
                'gulpfile.js',
                'gulpfile.coffee',
                'gulpfile.ts',
                'gulpfile.babel.js',
                'gulpfile.babel.coffee',
                'gulpfile.babel.ts'
            ]
        },
        { icon: 'haxelib', format: 'svg', names: ['.haxelib', 'haxe_libraries'] },
        { icon: 'helper', format: 'svg', names: ['helper', '.helper', 'helpers', '.helpers'] },
        { icon: 'hook', format: 'svg', names: ['hook', '.hook', 'hooks', '.hooks'] },
        { icon: 'husky', format: 'svg', names: ['.husky'] },
        { icon: 'idea', format: 'svg', names: ['.idea'] },
        {
            icon: 'images',
            format: 'svg',
            names: [
                'images',
                'image',
                'img',
                'imgs',
                'icons',
                'icon',
                'ico',
                'screenshot',
                'screenshots',
                'svg'
            ]
        },
        {
            icon: 'include',
            format: 'svg',
            names: [
                'include',
                'includes',
                'incl',
                'inc',
                '.include',
                '.includes',
                '.incl',
                '.inc',
                '_include',
                '_includes',
                '_incl',
                '_inc'
            ]
        },
        { icon: 'interfaces', format: 'svg', names: ['interface', 'interfaces'] },
        { icon: 'ios', format: 'svg', names: ['ios'] },
        { icon: 'js', format: 'svg', names: ['js'] },
        { icon: 'json', format: 'svg', names: ['json'] },
        {
            icon: 'kubernetes',
            format: 'svg',
            names: ['kubernetes', 'k8s', 'kube', 'kuber', '.kubernetes', '.k8s', '.kube', '.kuber']
        },
        { icon: 'less', format: 'svg', names: ['less', '_less'] },
        {
            icon: 'library',
            format: 'svg',
            names: ['lib', 'libs', '.lib', '.libs', 'library', 'libraries']
        },
        { icon: 'linux', format: 'svg', names: ['linux'] },
        {
            icon: 'locale',
            format: 'svg',
            names: [
                'lang',
                'language',
                'languages',
                'locale',
                'locales',
                '_locale',
                '_locales',
                'internationalization',
                'globalization',
                'localization',
                'i18n',
                'g11n',
                'l10n'
            ]
        },
        { icon: 'log', format: 'svg', names: ['log', 'logs'] },
        { icon: 'macos', format: 'svg', names: ['macos', 'darwin'] },
        { icon: 'mariadb', format: 'svg', names: ['mariadb', 'maria'] },
        { icon: 'maven', format: 'svg', names: ['.mvn'] },
        { icon: 'mediawiki', format: 'svg', names: ['mediawiki'] },
        { icon: 'memcached', format: 'svg', names: ['memcached', '.memcached'] },
        { icon: 'meteor', light: true, format: 'svg', names: ['.meteor'] },
        { icon: 'middleware', format: 'svg', names: ['middleware', 'middlewares'] },
        { icon: 'mjml', format: 'svg', names: ['mjml', '.mjml'] },
        { icon: 'minikube', format: 'svg', names: ['minikube', 'minik8s', 'minikuber'] },
        { icon: 'mojo', format: 'svg', names: ['mojo'] },
        { icon: 'mock', format: 'svg', names: ['mocks', '.mocks', '__mocks__'] },
        {
            icon: 'model',
            format: 'svg',
            names: ['model', '.model', 'models', '.models', 'entities', '.entities']
        },
        { icon: 'module', format: 'svg', names: ['modules'] },
        { icon: 'mongodb', format: 'svg', names: ['mongodb', 'mongo'] },
        { icon: 'mysql', light: true, format: 'svg', names: ['mysqldb', 'mysql'] },
        { icon: 'next', format: 'svg', names: ['.next'] },
        { icon: 'nginx', format: 'svg', names: ['nginx', 'conf.d'] },
        { icon: 'nix', format: 'svg', names: ['.niv', '.nix', 'nix', 'niv'] },
        { icon: 'node', light: true, format: 'svg', names: ['node_modules'] },
        { icon: 'notebooks', format: 'svg', names: ['notebooks', 'notebook'] },
        {
            icon: 'notification',
            format: 'svg',
            names: ['notification', 'notifications', 'event', 'events']
        },
        { icon: 'nuget', format: 'svg', names: ['.nuget'] },
        {
            icon: 'package',
            format: 'svg',
            names: ['package', 'packages', '.package', '.packages', 'pkg']
        },
        { icon: 'paket', format: 'svg', names: ['.paket'] },
        { icon: 'php', format: 'svg', names: ['php'] },
        { icon: 'platformio', format: 'svg', names: ['.pio', '.pioenvs'] },
        {
            icon: 'plugin',
            format: 'svg',
            names: [
                'plugin',
                '.plugin',
                'plugins',
                '.plugins',
                'extension',
                '.extension',
                'extensions',
                '.extensions'
            ]
        },
        { icon: 'prisma', format: 'svg', names: ['prisma'] },
        { icon: 'private', format: 'svg', names: ['private', '.private'] },
        { icon: 'public', format: 'svg', names: ['public', '.public'] },
        {
            icon: 'python',
            format: 'svg',
            names: ['.venv', '.virtualenv', '__pycache__', '.pytest_cache']
        },
        { icon: 'vercel', format: 'svg', names: ['.vercel'] },
        { icon: 'redis', format: 'svg', names: ['redis'] },
        { icon: 'ravendb', format: 'svg', names: ['ravendb'] },
        {
            icon: 'route',
            format: 'svg',
            names: ['route', 'routes', '_route', '_routes', 'router', 'routers']
        },
        { icon: 'redux', light: true, format: 'svg', names: ['redux'] },
        { icon: 'nuxt', format: 'svg', names: ['nuxt', '.nuxt'] },
        { icon: 'sass', light: true, format: 'svg', names: ['sass', 'scss', '_sass', '_scss'] },
        { icon: 'script', format: 'svg', names: ['script', 'scripts'] },
        { icon: 'server', format: 'svg', names: ['server'] },
        { icon: 'services', format: 'svg', names: ['service', 'services'] },
        {
            icon: 'shared',
            format: 'svg',
            names: ['share', 'shared', '.share', '.shared', '__shared__', '__share__']
        },
        { icon: 'snaplet', format: 'svg', names: ['.snaplet'] },
        { icon: 'spin', format: 'svg', names: ['.spin'] },
        { icon: 'src', format: 'svg', names: ['src', 'source', 'sources'] },
        { icon: 'sso', format: 'svg', names: ['sso'] },
        {
            icon: 'story',
            format: 'svg',
            names: ['story', 'stories', '__stories__', '.storybook']
        },
        { icon: 'style', format: 'svg', names: ['style', 'styles'] },
        { icon: 'supabase', format: 'svg', names: ['supabase'] },
        { icon: 'svelte', format: 'svg', names: ['svelte', '.svelte-kit'] },
        { icon: 'tauri', format: 'svg', names: ['src-tauri'] },
        {
            icon: 'test',
            format: 'svg',
            names: [
                'tests',
                '.tests',
                'test',
                '.test',
                '__tests__',
                '__test__',
                'spec',
                '.spec',
                'specs',
                '.specs',
                'integration'
            ]
        },
        { icon: 'temp', format: 'svg', names: ['temp', '.temp', 'tmp', '.tmp'] },
        {
            icon: 'template',
            format: 'svg',
            names: ['template', '.template', 'templates', '.templates']
        },
        { icon: 'theme', format: 'svg', names: ['theme', 'themes'] },
        { icon: 'travis', format: 'svg', names: ['.travis'] },
        {
            icon: 'tools',
            format: 'svg',
            names: ['tool', 'tools', '.tools', 'util', 'utils', 'utilities']
        },
        { icon: 'trunk', format: 'svg', names: ['.trunk'] },
        { icon: 'turbo', format: 'svg', names: ['.turbo'] },
        { icon: 'typescript', format: 'svg', names: ['typescript', 'ts'] },
        { icon: 'typings', format: 'svg', names: ['typings', 'types', '@types'] },
        { icon: 'vagrant', format: 'svg', names: ['vagrant', '.vagrant'] },
        { icon: 'video', format: 'svg', names: ['video', '.video', 'videos', '.videos'] },
        {
            icon: 'view',
            format: 'svg',
            names: [
                'html',
                'view',
                'views',
                'layout',
                'layouts',
                'page',
                'pages',
                '_view',
                '_views',
                '_layout',
                '_layouts',
                '_page',
                '_pages'
            ]
        },
        { icon: 'vs', format: 'svg', names: ['.vs'] },
        { icon: 'vscode', format: 'svg', names: ['.vscode', 'vscode'] },
        { icon: 'vscode_test', format: 'svg', names: ['.vscode-test'] },
        { icon: 'wit', format: 'svg', names: ['wit'] },
        { icon: 'webpack', format: 'svg', names: ['webpack', '.webpack'] },
        { icon: 'windows', format: 'svg', names: ['windows', 'win32'] },
        { icon: 'www', format: 'svg', names: ['www', 'wwwroot', 'web'] },
        { icon: 'yarn', format: 'svg', names: ['.yarn'] },
        { icon: 'pnpm', format: 'svg', names: ['.pnpm-store'] },
        { icon: 'home', format: 'svg', names: ['root'] },
        { icon: 'trashcan', format: 'svg', names: ['回收站'] }
    ]
}

let names = new Map()

defs.supported.forEach(it => {
    it.names.forEach(name => names.set(name, it))
})

module.exports = function (name, isRoot) {
    let icon = names.get(name)
    if (icon) {
        return icon
    }
    if (isRoot) {
        return defs.default
    }
    return defs.default
}
